/**
 * Created by 84995 on 2020/1/16.
 */
public class test12 {

    public static void main(String[] args) {


        String[][]  all = {
                {"张三","37","89","5"},
                {"李四","95","41","79"},
                {"王五","60","84","29"},
                {"赵六","87","46","86"}
        };

        //数学成绩
        printMathScore(all);
        //数学成绩总和
        int aa = getCountMathScore(all);
        System.out.println("数学总和"+aa);
        //数学超过平均成绩的名字
        getAvgMathScore(all);
        //数学超过平均成绩的人数
        getAvgCount(all);

        get(all);

    }
    public static void get(String[][]  all){

        int man=0,man1=0,man2=0;

        for (int i = 0; i <all.length ; i++) {
            int i1 = Integer.parseInt(all[i][1]);
            int i2 = Integer.parseInt(all[i][2]);
            int i3 = Integer.parseInt(all[i][3]);
            man=i1/all.length;
            man1=i2/all.length;
            man2=i3/all.length;
        }

        int s=man>man1?man:man2;
        s=s>man2?s:man2;
        if (s==man){
            System.out.println("最高是语文");
        }else if (s==man1){
            System.out.println("最高是数学");
        }else if (s==man2){
            System.out.println("最高是英语");
        }

        int min=0;
        for (int i = 0; i <all.length ; i++) {
            if (min<Integer.parseInt(all[i][1])){
                min=Integer.parseInt(all[i][1]);
            }
        }

        for (int i = 0; i <all.length ; i++) {
            if (min!=Integer.parseInt(all[i][1])){
                System.out.println("前三名的同学"+all[i][0]);
            }
        }

        for (int i = 0; i <all.length ; i++) {
            int aa=0;
            int sun=0;
            for (int j = 1; j < all.length ; j++) {
                sun+=Integer.parseInt(all[i][j]);
                if (Integer.parseInt(all[i][j])<60){
                    aa++;
                }
            }

            if (aa>=1&&sun>180){
                System.out.println("不及格的科数小于等于1门的同学，且总成绩大于180分:"+all[i][0]);
            }
        }

    }

    public static void getAvgCount (String[][]  all ){

        int zhe = getCountMathScore(all);
        int pjzj = zhe / all.length;
        int count=0;
        for (int i = 0; i <all.length; i++) {
            int aa=Integer.parseInt(all[i][2]);
            if (aa>pjzj){
               count++;
            }
        }
        System.out.println("有："+count+"人");
    }

    public static void getAvgMathScore(String[][]  all ){

        int zhe = getCountMathScore(all);
        int pjzj = zhe / all.length;
        for (int i = 0; i <all.length; i++) {
            int aa=Integer.parseInt(all[i][2]);
            if (aa>pjzj){
                System.out.println("人有"+all[i][0]);
            }
        }
    }

    public static int getCountMathScore(String[][]  all ){

        int sum=0;
        for (int i = 0; i <all.length; i++) {
            sum+=Integer.parseInt(all[i][2]);
        }
        return sum;

    }
    public static void printMathScore(String[][]  all ){

        for (int i = 0; i <all.length; i++) {
            System.out.println(all[i][2]);
        }
    }
}
